package com.jianyushe.mysqltest.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jianyushe.mysqltest.entity.Sc;
import com.jianyushe.mysqltest.mapper.ScMapper;
import com.jianyushe.mysqltest.service.IScService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Alvin
 * @since 2022-05-08
 */
@Service
public class ScServiceImpl extends ServiceImpl<ScMapper, Sc> implements IScService {

    @Autowired
    ScMapper scMapper;

    /**
     * 查询“c001”课程比“c002”课程成绩高的所有学生的学号；
     *
     * @return
     */

    public List<Sc> selectSnoByCompareScore() {
        QueryWrapper<Sc> wrapper = new QueryWrapper<>();
        List<Sc> scList = scMapper.selectSnoByCompareScore();
        System.out.println("scList结果为:");
        scList.forEach(System.out::println);

        return scList;
    }

    public Sc queryById(Sc sc) {
        Sc scResult = scMapper.queryById(sc);
        System.out.println("sc: " +sc);
        System.out.println("查询结果为： " + scResult);

        return sc;
    }

}
